package com.kele.service.impl;

import com.kele.entity.Document;
import com.kele.mapper.DocumentMapper;
import com.kele.service.DocumentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Version 2019
 * @Author:kele
 * @Date:2020/11/16
 * @Content:
 * @Description：
 */
@Service
public class DocumentServiceImpl implements DocumentService {

    @Autowired
    private DocumentMapper documentMapper;

    @Override
    public List<Document> getAll() {
        List<Document> listAll = documentMapper.getAll();

        return listAll;
    }

    @Override
    public Document findById(int document_id) {

        Document document=null;
        document = documentMapper.findById(document_id);

        if (document==null){
            System.out.println("无法查询到相关内容");
        }else {
            System.out.println("查询成功");
        }

        return  document;
    }

    @Override
    public List<Document> getDocumentByCustName(String cust_name) {

        List<Document> list=null;
        list=documentMapper.getDocumentByCustName(cust_name);
        return list;
    }

    @Override
    public boolean addDocument(Document document) {
        boolean isSuccess=false;
        isSuccess=documentMapper.addDocument(document);
        if (isSuccess){
            System.out.println("插入成功");
        }else {
            System.out.println("插入失败");
        }
        return isSuccess;
    }

    @Override
    public boolean editDocument(Document document) {
        boolean isSuccess=false;
        isSuccess=documentMapper.editDocument(document);
        if (isSuccess){
            System.out.println("修改成功");
        }else{
            System.out.println("修改失败");
        }
        return isSuccess;
    }

    @Override
    public boolean delDocument(int document_id){

        boolean isSuccess=false;
        isSuccess=documentMapper.delDocument(document_id);
        if (isSuccess){
            System.out.println("删除成功");
        }else {
            System.out.println("删除失败");
        }

        return isSuccess;
    }
}
